package cc.software.books.format;

import android.util.Log;

public class Plugin
{
   public final static int CHM_PROPERTY_INDEX = 14;
   public final static int CHM_PROPERTY_DATA  = 16;
   
   public int handle = 0;

   public int open(String name){
          handle = book_open(name); 
          return handle;
          };

   public int get(int prop,int flag){ 
	   	  Param param = new Param();
       	  param.i =flag;
       	  
       	  Log.d("vrix",Integer.toString(flag));
          int ret = book_get(handle,prop,param);
          return ret;
          };
          
   public String getData(String url)
   {
	   	  Param param = new Param();
	   	  param.str = url;	   	  
	      int ret = book_get(handle,CHM_PROPERTY_DATA,param);
	      //Log.d("vrix",param.str);
	      return param.str;
   }
     // 
   public String getIndex(){ 
	   	  Param param = new Param();
	   	  param.str = "";	   	  
	      int ret = book_get(handle,CHM_PROPERTY_INDEX,param);
	      Log.d("vrix",param.str);
	      return param.str;
      };

   public void close(){
          book_close(handle);
          };

   //--------------------------------------------------------------------- native api
   public native int book_open(String name);
   public native int book_get(int handle,int prop,Param param);
   public native void book_close(int f);
   
   static {
	System.loadLibrary("chm");
   };
};
